Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[METRICS] use built-in cost functions to fetch beans #1622

Merged
merged 7 commits into from
Mar 30, 2023

Conversation

chia7712
Copy link
Contributor

取代原本索取全部 metrics 的設計,這邊用內建的 cost functions 的查詢條件來索取,”理論上“會少垃很多資料

Collection<BeanQuery> QUERIES =
Stream.of(
LogMetrics.QUERIES.stream(),
LogMetrics.QUERIES.stream(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這裡出現重複的 query 。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感謝!

你這個建議倒是提醒了另一件事情,你覺得我們這些內建的query中有沒有查找到重複內容?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起來 domain name 就不重複了,應該沒有拉到重複的內容。

另外也有實際測試過了,沒有重複。

@Test
  void testing(){
    try (var client = MBeanClient.jndi("localhost", 7091)){
      Set<Map<String, String>> exist = new HashSet<>();
      MetricFetcher.QUERIES.forEach(q -> client.beans(q).forEach(bean ->{
        if (exist.contains(bean.properties())){
          System.out.println("  same properties for: "+ bean.properties());
        }else {
          exist.add(bean.properties());
        }
      }));
      System.out.println("All beans:"+exist.size());
    }
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這個例子看起來不錯,我把它加入PR

@chia7712 chia7712 merged commit 55bc78e into opensource4you:main Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants